package com.youan.pangu.base.bean;

import com.youan.pangu.base.bean.GlobalValue;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @description: 系统运行参数
 * @author: 辛晟昊
 * @time: 2020/3/7 20:10
 */
@Component
public class SystemParameter {
    private Logger logger = LoggerFactory.getLogger(GlobalValue.LOOGER_NAME);

    //  运行模式dev(开发模式)prod(正式模式)
    private String mode = "dev";

    //  系统中的自定义参数
    private Map<String, String> map ;


    public String getMode() {
        return mode;
    }

    public void setMode(String mode) {
        if(!StringUtils.equalsAnyIgnoreCase(mode, "dev", "prod")){
            logger.error("<mode>参数设置异常,值<{}>取消,使用默认值<dev>", mode);
            return;
        }
        this.mode = mode;
    }

    public Map<String, String> getMap() {
        return map;
    }

    public void setMap(Map<String, String> map) {
        this.map = map;
    }

    public String getParameter(String key) {
        return map.get(key);
    }
}
